package mysql

import (
	"class_rpc/appconfig"
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var (
	DB  *gorm.DB
	err error
)

func InitMysql() {
	a := appconfig.AppConf.MysqlConfig
	dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local", a.User, a.Password, a.Host, a.Port, a.DbName)
	DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	//DB.AutoMigrate(new(Comment))
}
